package com.tencent.sr.iris.basic.saas.dependency.activity;

import com.alibaba.fastjson.JSON;
import com.tencent.sr.iris.activity.interfaces.client.activity.ActivityBatchDataClient;
import com.tencent.sr.iris.activity.interfaces.request.IrisPaginationRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityTaskRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.BatchDataRequest;
import com.tencent.sr.iris.activity.interfaces.response.SearchAfterPaginationResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityTierResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.BatchDataResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.BatchStatisticsResponse;
import com.tencent.sr.iris.basic.saas.common.utils.HttpUtils;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component
@Slf4j
public class ActivityTaskDependency {

    @Resource
    private ActivityBatchDataClient activityBatchDataClient;

    public SearchAfterPaginationResponse<BatchDataResponse> page(IrisPaginationRequest<BatchDataRequest> request) {
        log.info("调用ActivityTaskDependency.page开始，请求参数：{}", JSON.toJSONString(request));
        HttpResult<SearchAfterPaginationResponse<BatchDataResponse>> page = activityBatchDataClient.page(request);
        log.info("调用ActivityTaskDependency.page结束，请求参数：{}，返回结果：{}", JSON.toJSONString(request), JSON.toJSONString(page));
        return HttpUtils.handleResult(page);
    }

    public BatchStatisticsResponse activityStatic(BatchDataRequest request) {
        log.info("调用ActivityTaskDependency.activityStatic开始，请求参数：{}", JSON.toJSONString(request));
        HttpResult<BatchStatisticsResponse> res = activityBatchDataClient.activityStatic(request);
        log.info("调用ActivityTaskDependency.activityStatic结束，请求参数：{}，返回结果：{}", JSON.toJSONString(request), JSON.toJSONString(request));
        return HttpUtils.handleResult(res);
    }

    public ActivityTierResponse getActivityMaxTier(ActivityTaskRequest request) {
        log.info("调用ActivityTaskDependency.getActivityMaxTier开始，请求参数：{}", JSON.toJSONString(request));
        HttpResult<ActivityTierResponse> res = activityBatchDataClient.getActivityMaxTier(request);
        log.info("调用ActivityTaskDependency.getActivityMaxTier结束，请求参数：{}，返回结果：{}", JSON.toJSONString(request), JSON.toJSONString(request));
        return HttpUtils.handleResult(res);
    }
}
